package de.mhus.lib.mandala;

import java.util.UUID;

public abstract class Element extends Sphere {

	private String id;

	public String getId() {
		if (id == null) {
			if (getWindow() != null) {
				id = getWindow().createId();
			} else {
				id = UUID.randomUUID().toString().replace('-', '_');
			}
		}
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}
	
	public void renderElementName(Response out) {
		out.registerElement(this);
		out.print(getWindow().getId());
		out.print(".");
		out.print(getId());
	}

	public void renderElementCall(Response out) {
		renderElementName(out);
		out.print("()");
	}
	
	public boolean needFunctionImplementation() {
		return true;
	}
	
}
